package shapes;

import java.awt.Color;

public class Shape {

	// 0 - PONTO
	// 1 - RETA
	// 2 - POLIGONO
	// 3 - BEZIER
	public int type;

	public double[][] pts;
	
	//pontos normalizados
	public double[][] ptsn;
	
	//pontos clipados
	public double[][] cpts;
	
	
	public double[] center = new double[2];

	public String name;
	public Color color;
	public Boolean solid;

	public void translate(double dx, double dy) {
		center[0] += dx;
		center[1] += dy;
		for (int i = 0; i < pts[0].length; i++) {
			pts[0][i] += dx;
			pts[1][i] += dy;
		}
	}

	public void scale(double sx, double sy) {
		for (int i = 0; i < pts[0].length; i++) {
			pts[0][i] *= sx;
			pts[1][i] *= sy;
		}
	}

	public void rotate(double x, double y, double grau) {
		double rad = Math.toRadians(-grau);
		double cos = Math.cos(rad);
		double sen = Math.sin(rad);
		translate(-x, -y);
		for (int i = 0; i < pts[0].length; i++) {
			double aux = (cos * pts[0][i]) + (sen * pts[1][i]);
			pts[1][i] = -(sen * pts[0][i]) + (cos * pts[1][i]);
			pts[0][i] = aux;
		}
		translate(x, y);
	}

}
